home *** CD-ROM | disk | FTP | other *** search
- class Sounds
- {
- static var mainSounds;
- static var mcSoundsHolder;
- static var soundsList;
- static var randomSoundNamesList;
- static var ambienceInterval;
- function Sounds()
- {
- }
- static function setSounds(Void)
- {
- if(Sounds.mainSounds == undefined)
- {
- Sounds.mainSounds = new Sound(_root);
- Sounds.mcSoundsHolder = _root.createEmptyMovieClip("mcSoundsHolder",_root.getNextHighestDepth());
- Sounds.init();
- Sounds.mainSoundUp();
- Sounds.playSound("loop3",99999);
- }
- }
- static function mainSoundUp(Void)
- {
- _root.mcSoundBtn.gotoAndStop("up");
- _root.mcSoundBtn.btnSound.onRelease = Sounds.mainSoundDown;
- Sounds.mainSounds.setVolume(100);
- }
- static function mainSoundDown(Void)
- {
- _root.mcSoundBtn.gotoAndStop("down");
- _root.mcSoundBtn.btnSound.onRelease = Sounds.mainSoundUp;
- Sounds.mainSounds.setVolume(0);
- }
- static function init(Void)
- {
- var _loc6_ = new Array("airnuke","ak47","CHOPPER2","bazooka","explos","explsion","gunfire","missile_snd","warning_alarm","loop3");
- Sounds.soundsList = new Object();
- var _loc5_ = _loc6_.length;
- var _loc2_ = 0;
- while(_loc2_ < _loc5_)
- {
- var _loc1_ = _loc6_[_loc2_];
- var _loc4_ = Sounds.mcSoundsHolder.createEmptyMovieClip("holder" + _loc2_,_loc2_);
- Sounds.soundsList[_loc1_] = new Sound(_loc4_);
- Sounds.soundsList[_loc1_].attachSound(_loc1_);
- _loc2_ = _loc2_ + 1;
- }
- Sounds.setVolume("ak47",150);
- Sounds.setVolume("CHOPPER2",50);
- Sounds.setVolume("explsion",150);
- Sounds.randomSoundNamesList = new Array("30cal5","auto","explos","helicopt","machinegun","tankfire");
- _loc5_ = Sounds.randomSoundNamesList.length;
- _loc2_ = 0;
- while(_loc2_ < _loc5_)
- {
- _loc1_ = Sounds.randomSoundNamesList[_loc2_];
- if(Sounds.soundsList[_loc1_] == undefined)
- {
- var _loc3_ = Sounds.mcSoundsHolder.getNextHighestDepth();
- _loc4_ = Sounds.mcSoundsHolder.createEmptyMovieClip("holder" + _loc3_,_loc3_);
- Sounds.soundsList[_loc1_] = new Sound(_loc4_);
- Sounds.soundsList[_loc1_].attachSound(_loc1_);
- }
- _loc2_ = _loc2_ + 1;
- }
- }
- static function playSound(name, loops)
- {
- if(loops == undefined)
- {
- loops = 0;
- }
- Sounds.soundsList[name].start(0,loops);
- }
- static function stopSound(name)
- {
- Sounds.soundsList[name].stop();
- }
- static function stopAllSounds(sExcept)
- {
- for(var _loc1_ in Sounds.soundsList)
- {
- if(_loc1_ != sExcept)
- {
- Sounds.stopSound(_loc1_);
- }
- }
- }
- static function setVolume(name, volume)
- {
- Sounds.soundsList[name].setVolume(volume);
- }
- static function getVolume(name)
- {
- return Sounds.soundsList[name].getVolume();
- }
- static function playAmbience(Void)
- {
- var _loc2_ = Sounds.randomSoundNamesList.length;
- var _loc3_ = Math.floor(_loc2_ * Math.random());
- var _loc1_ = Sounds.randomSoundNamesList[_loc3_];
- var _loc4_ = 20 + Math.floor(15 * Math.random());
- Sounds.setVolume(_loc1_,_loc4_);
- Sounds.playSound(_loc1_,0);
- Sounds.stopAmbience();
- Sounds.startAmbience();
- }
- static function startAmbience(bFirst)
- {
- var _loc1_ = undefined;
- if(bFirst)
- {
- _loc1_ = 1000 + Math.round(1000 * Math.random());
- }
- else
- {
- _loc1_ = 1000 + Math.round(1000 * Math.random());
- }
- Sounds.ambienceInterval = setInterval(Sounds.playAmbience,_loc1_);
- }
- static function stopAmbience()
- {
- clearInterval(Sounds.ambienceInterval);
- }
- }
-